package come.bjpowernode.javase.reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

//了解一下不需要掌握
public class ReflectTest09 {
    public static void main(String[] args) throws Exception {
        //Class userService = Class.forName("come.bjpowernode.javase.reflect.service.UserService");
        Class userService = Class.forName("java.lang.String");
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(Modifier.toString(userService.getModifiers())+
                " class "+ userService.getSimpleName()+"{\n");

        //public boolean login(String naem,String password){
        Method[] methods = userService.getDeclaredMethods();
        for(Method method : methods){
            stringBuilder.append("\t");
            stringBuilder.append(Modifier.toString(method.getModifiers()));
            stringBuilder.append(" ");
            stringBuilder.append(method.getReturnType().getSimpleName());
            stringBuilder.append(" ");
            stringBuilder.append(method.getName());
            stringBuilder.append("(");
            //参数列表
            Class[] parametersTypes = method.getParameterTypes();
            for(Class parametersType :parametersTypes){
                stringBuilder.append(parametersType.getSimpleName());
                stringBuilder.append(",");
            }
            stringBuilder.deleteCharAt(stringBuilder.length()-1);
            //删除指定下标位置上的字符
            stringBuilder.append("){}\n");
        }
        stringBuilder.append("}");
        System.out.println(stringBuilder);
    }
}
